package Q5;

/*
扑克牌对象
* */
public class pokerCard implements Comparable<pokerCard> {
    String suit;
    String call;
    int value;

    public pokerCard(String suit, String call, int value) {
        this.suit = suit;
        this.call = call;
        this.value = value;
    }

    public String getSuit() {
        return suit;
    }

    public void setSuit(String suit) {
        this.suit = suit;
    }

    public String getCall() {
        return call;
    }

    public void setCall(String call) {
        this.call = call;
    }

    public int getValue() {
        return value;
    }

    public void setValue(int value) {
        this.value = value;
    }

    @Override
    public String toString() {
        return suit + '\''+ call + '\'';
    }

    @Override
    public int compareTo(pokerCard o) {
        if(0 == (o.getValue() - this.getValue())){
            return this.getSuit().compareTo(o.getSuit());
        }
        else{
        return o.getValue() - this.getValue();
        }
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof pokerCard){
            pokerCard card = (pokerCard) obj;
            if(card.getSuit().equals(this.getSuit())&&card.getValue() == this.getValue()&&card.getCall().equals(this.getCall())){
                return true;
            }else {return false;}
        }
        else{return false;}
    }
}
